package Track6;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        List<Integer> list=new ArrayList<>();
        Collections.addAll(list,100,200,4,800,230,420);
        MyCallable myCallable=new MyCallable(list);

        FutureTask<Integer> futureTask1=new FutureTask<>(myCallable);
        FutureTask<Integer> futureTask2=new FutureTask<>(myCallable);

        Thread thread =new Thread(futureTask1);
        Thread thread1=new Thread(futureTask2);

        thread .setName("抽奖箱1");
        thread1.setName("抽奖箱2");


        thread.start();
        thread1.start();

        System.out.println(futureTask1.get());
        System.out.println(futureTask2.get());


    }
}
